/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package letterbox;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;

/**
 * @author mk2g10
 */
public class Window extends JFrame implements ActionListener{
    private static final int WIDTH = 710;
    private static final int HEIGHT = 420;
    private static final int OFF_W = 6;
    private static final int OFF_H = 49;
    private static JMenuBar menubar;

    public Window(){
        super.setTitle("CW1 COMP1001 | mk2g10");
        super.setBounds(0, 0, WIDTH + OFF_W, HEIGHT + OFF_H);
        super.setResizable(false);
        super.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }

    public void configure(){
        menubar = new JMenuBar();
        String[] items = {"a", "b", "Quit"};
        menubar.add(this.getMenu("Options", items));
        this.setJMenuBar(menubar);
        super.setFocusable(true);
        super.setVisible(true);
    }


    public JMenu getMenu(String title, String[] items){
        JMenu jm = new JMenu(title);
        for(String i : items){
            JMenuItem jmi = new JMenuItem(i);
            jmi.addActionListener(this);
            jm.add(jmi);
        }
        return jm;
    }

    public void actionPerformed(ActionEvent e) {
        if(e.getSource() instanceof JMenuItem){
            JMenuItem item = (JMenuItem)e.getSource();
            if(item.getText().equals("Quit")){
                System.exit(0);
            }
        }
    }
    
    public static void main(String[] args) {
        Window w = new Window();
        w.configure();
    }
}
